import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App'
import { RouterProvider } from 'react-router-dom'
import router from './router/index.tsx'

// 动态设置根元素字体大小（保留原始方案，注释掉 amfe-flexible 引入）
function setRootFontSize(): void {
  const docEl: HTMLElement = document.documentElement
  const clientWidth: number = docEl.clientWidth
  // 假设设计稿宽度为 750px
  if (clientWidth >= 320) {
    docEl.style.fontSize = '100px'
  } else {
    docEl.style.fontSize = 100 * (clientWidth / 320) + 'px'
  }
}

// 监听窗口大小变化，重新设置根元素字体大小
window.addEventListener('resize', setRootFontSize)
// 初始化设置根元素字体大小
setRootFontSize()

const rootElement = document.getElementById('root')
if (!rootElement) throw new Error('Failed to find the root element')

createRoot(rootElement).render(
  <StrictMode>
    {/* 使用 RouterProvider 替代 BrowserRouter */}
    <RouterProvider router={router} />
import { RouterProvider } from 'react-router-dom';
import { Provider } from 'react-redux'
import store from './store/index.tsx'
createRoot(document.getElementById('root')!).render(
  <StrictMode>
      {/* <App /> */}
      <Provider store={store}>
        <RouterProvider router={router}/>
      </Provider>
  </StrictMode>
)